﻿<%@ Page Language="C#" MasterPageFile="~/Game/GameTools/GameTool.Master" AutoEventWireup="true" CodeBehind="Battles.aspx.cs" Inherits="smallDeimos.Game.GameTools.Battles" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
Show battles for player (type player name): 
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1"
        runat="server" Text="Submit" onclick="Button1_Click" /><br />
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
        SelectMethod="GetBattlesForPlayer" TypeName="SD.Database.DataAccess">
        <SelectParameters>
            <asp:QueryStringParameter Name="pId" QueryStringField="pId" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
        DataSourceID="ObjectDataSource1" AutoGenerateColumns="true">
        <EmptyDataTemplate>
            There is no data for this player.
        </EmptyDataTemplate>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:smallDeimosConnectionString %>" 
        
        SelectCommand="SELECT Distinct (SELECT PlayerName FROM Players WHERE (PlayerId = Battles.AttackerID)) AS Attacker, Battles.AttackerCV, (SELECT PlayerName FROM Players AS Players_2 WHERE (PlayerId = Battles.DefenderId)) AS Defender, Battles.DefenderCV, Battles.Date, Systems.SystemName AS System, Battles.PlanetId AS Planet, (SELECT PlayerName FROM Players AS Players_3 WHERE (PlayerId = Battles.WinnerId)) AS Winner FROM Systems INNER JOIN Battles ON Systems.SystemID = Battles.SystemId CROSS JOIN Players AS Players_1 WHERE (Battles.AttackerID = @pId) OR (Battles.DefenderId = @pId) ORDER BY Battles.Date DESC">
        <SelectParameters>
            <asp:QueryStringParameter Name="pId" QueryStringField="pId" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br />
        
</asp:Content>
